# -*- coding: utf-8 -*-
from odoo import models, fields, api

class PriceListPurchaseOrder(models.Model):
    _inherit = 'purchase.order'

    remarks = fields.Text(string='收貨備註')
    client_order_ref = fields.Char(string='客戶關聯單號')


    @api.multi
    def button_confirm(self):
        res = super(PriceListPurchaseOrder, self).button_confirm()
        stock_picking_id = self.env['stock.picking'].search([('origin','=',self.name),('state','=','assigned')],limit=1)
        if stock_picking_id:
            stock_picking_id.remarks = self.remarks
            stock_picking_id.client_order_ref = self.client_order_ref
        return res
